package sys.fsm;


/* package */ final class AutomatContext
    extends statemap.FSMContext
{
//---------------------------------------------------------------
// Member methods.
//

    public AutomatContext(Automat owner)
    {
        super();

        _owner = owner;
        setState(AutomatFSM.Start);
        AutomatFSM.Start.Entry(this);
    }

    public AutomatContext(Automat owner, AutomatState initState)
    {
        super();
        _owner = owner;
        setState(initState);
        initState.Entry(this);
    }

    public void Ack_PayingSystem_1_T()
    {
        _transition = "Ack_PayingSystem_1_T";
        getState().Ack_PayingSystem_1_T(this);
        _transition = "";
        return;
    }

    public void Ack_Seller_1_T()
    {
        _transition = "Ack_Seller_1_T";
        getState().Ack_Seller_1_T(this);
        _transition = "";
        return;
    }

    public void Ack_Seller_2_T()
    {
        _transition = "Ack_Seller_2_T";
        getState().Ack_Seller_2_T(this);
        _transition = "";
        return;
    }

    public void Ack_User_1_T()
    {
        _transition = "Ack_User_1_T";
        getState().Ack_User_1_T(this);
        _transition = "";
        return;
    }

    public void Nack_Seller_1_T()
    {
        _transition = "Nack_Seller_1_T";
        getState().Nack_Seller_1_T(this);
        _transition = "";
        return;
    }

    public void Nack_User_1_T()
    {
        _transition = "Nack_User_1_T";
        getState().Nack_User_1_T(this);
        _transition = "";
        return;
    }

    public void Start(long Id, String PSAddress, String userName, int quantity)
    {
        _transition = "Start";
        getState().Start(this, Id, PSAddress, userName, quantity);
        _transition = "";
        return;
    }

    public void Timeout_1_T()
    {
        _transition = "Timeout_1_T";
        getState().Timeout_1_T(this);
        _transition = "";
        return;
    }

    public void Timeout_2_T()
    {
        _transition = "Timeout_2_T";
        getState().Timeout_2_T(this);
        _transition = "";
        return;
    }

    public void Timeout_3_T()
    {
        _transition = "Timeout_3_T";
        getState().Timeout_3_T(this);
        _transition = "";
        return;
    }

    public void Timeout_4_T()
    {
        _transition = "Timeout_4_T";
        getState().Timeout_4_T(this);
        _transition = "";
        return;
    }

    public AutomatState getState()
        throws statemap.StateUndefinedException
    {
        if (_state == null)
        {
            throw(
                new statemap.StateUndefinedException());
        }

        return ((AutomatState) _state);
    }

    protected Automat getOwner()
    {
        return (_owner);
    }

    public void setOwner(Automat owner)
    {
        if (owner == null)
        {
            throw (
                new NullPointerException(
                    "null owner"));
        }
        else
        {
            _owner = owner;
        }

        return;
    }

//---------------------------------------------------------------
// Member data.
//

    transient private Automat _owner;

//---------------------------------------------------------------
// Inner classes.
//

    public static abstract class AutomatState
        extends statemap.State
    {
    //-----------------------------------------------------------
    // Member methods.
    //

        protected AutomatState(String name, int id)
        {
            super (name, id);
        }

        protected void Entry(AutomatContext context) {}
        protected void Exit(AutomatContext context) {}

        protected void Ack_PayingSystem_1_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Ack_Seller_1_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Ack_Seller_2_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Ack_User_1_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Nack_Seller_1_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Nack_User_1_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Start(AutomatContext context, long Id, String PSAddress, String userName, int quantity)
        {
            Default(context);
        }

        protected void Timeout_1_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Timeout_2_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Timeout_3_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Timeout_4_T(AutomatContext context)
        {
            Default(context);
        }

        protected void Default(AutomatContext context)
        {
            throw (
                new statemap.TransitionUndefinedException(
                    "State: " +
                    context.getState().getName() +
                    ", Transition: " +
                    context.getTransition()));
        }

    //-----------------------------------------------------------
    // Member data.
    //
    }

    /* package */ static abstract class AutomatFSM
    {
    //-----------------------------------------------------------
    // Member methods.
    //

    //-----------------------------------------------------------
    // Member data.
    //

        //-------------------------------------------------------
        // Constants.
        //
        public static final AutomatFSM_Default.AutomatFSM_Start Start =
            new AutomatFSM_Default.AutomatFSM_Start("AutomatFSM.Start", 0);
        public static final AutomatFSM_Default.AutomatFSM_Wait_Seller_1_S Wait_Seller_1_S =
            new AutomatFSM_Default.AutomatFSM_Wait_Seller_1_S("AutomatFSM.Wait_Seller_1_S", 1);
        public static final AutomatFSM_Default.AutomatFSM_Wait_PayingSystem_1_S Wait_PayingSystem_1_S =
            new AutomatFSM_Default.AutomatFSM_Wait_PayingSystem_1_S("AutomatFSM.Wait_PayingSystem_1_S", 2);
        public static final AutomatFSM_Default.AutomatFSM_Wait_User_1_S Wait_User_1_S =
            new AutomatFSM_Default.AutomatFSM_Wait_User_1_S("AutomatFSM.Wait_User_1_S", 3);
        public static final AutomatFSM_Default.AutomatFSM_Wait_Seller_2_S Wait_Seller_2_S =
            new AutomatFSM_Default.AutomatFSM_Wait_Seller_2_S("AutomatFSM.Wait_Seller_2_S", 4);
        public static final AutomatFSM_Default.AutomatFSM_Cancel_S Cancel_S =
            new AutomatFSM_Default.AutomatFSM_Cancel_S("AutomatFSM.Cancel_S", 5);
        public static final AutomatFSM_Default.AutomatFSM_Done_S Done_S =
            new AutomatFSM_Default.AutomatFSM_Done_S("AutomatFSM.Done_S", 6);
        private static final AutomatFSM_Default Default =
            new AutomatFSM_Default("AutomatFSM.Default", -1);

    }

    protected static class AutomatFSM_Default
        extends AutomatState
    {
    //-----------------------------------------------------------
    // Member methods.
    //

        protected AutomatFSM_Default(String name, int id)
        {
            super (name, id);
        }

    //-----------------------------------------------------------
    // Inner classse.
    //


        private static final class AutomatFSM_Start
            extends AutomatFSM_Default
        {
        //-------------------------------------------------------
        // Member methods.
        //

            private AutomatFSM_Start(String name, int id)
            {
                super (name, id);
            }

            protected void Start(AutomatContext context, long Id, String PSAddress, String userName, int quantity)
            {
                Automat ctxt = context.getOwner();


                (context.getState()).Exit(context);
                context.clearState();
                try
                {
                    ctxt.start_A(Id, PSAddress, userName, quantity);
                }
                finally
                {
                    context.setState(AutomatFSM.Wait_Seller_1_S);
                    (context.getState()).Entry(context);
                }
                return;
            }

        //-------------------------------------------------------
        // Member data.
        //
        }

        private static final class AutomatFSM_Wait_Seller_1_S
            extends AutomatFSM_Default
        {
        //-------------------------------------------------------
        // Member methods.
        //

            private AutomatFSM_Wait_Seller_1_S(String name, int id)
            {
                super (name, id);
            }

            protected void Entry(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                ctxt.wait_Seller_1_Entry_A();
                return;
            }

            protected void Ack_Seller_1_T(AutomatContext context)
            {
                Automat ctxt = context.getOwner();


                (context.getState()).Exit(context);
                context.clearState();
                try
                {
                    ctxt.ack_Seller_1_A();
                }
                finally
                {
                    context.setState(AutomatFSM.Wait_PayingSystem_1_S);
                    (context.getState()).Entry(context);
                }
                return;
            }

            protected void Nack_Seller_1_T(AutomatContext context)
            {


                (context.getState()).Exit(context);
                context.setState(AutomatFSM.Cancel_S);
                (context.getState()).Entry(context);
                return;
            }

            protected void Timeout_1_T(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                if (ctxt.checkTimeout_1_Times() == true)
                {
                    AutomatState endState = context.getState();

                    context.clearState();
                    try
                    {
                        ctxt.timeout_1_A();
                    }
                    finally
                    {
                        context.setState(endState);
                    }
                }
                else
                {

                    (context.getState()).Exit(context);
                    context.setState(AutomatFSM.Cancel_S);
                    (context.getState()).Entry(context);
                }

                return;
            }

        //-------------------------------------------------------
        // Member data.
        //
        }

        private static final class AutomatFSM_Wait_PayingSystem_1_S
            extends AutomatFSM_Default
        {
        //-------------------------------------------------------
        // Member methods.
        //

            private AutomatFSM_Wait_PayingSystem_1_S(String name, int id)
            {
                super (name, id);
            }

            protected void Entry(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                ctxt.wait_PayingSystem_1_Entry_A();
                return;
            }

            protected void Ack_PayingSystem_1_T(AutomatContext context)
            {
                Automat ctxt = context.getOwner();


                (context.getState()).Exit(context);
                context.clearState();
                try
                {
                    ctxt.ack_PayingSystem_1_A();
                }
                finally
                {
                    context.setState(AutomatFSM.Wait_User_1_S);
                    (context.getState()).Entry(context);
                }
                return;
            }

            protected void Timeout_2_T(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                if (ctxt.checkTimeout_2_Times() == true)
                {
                    AutomatState endState = context.getState();

                    context.clearState();
                    try
                    {
                        ctxt.timeout_2_A();
                    }
                    finally
                    {
                        context.setState(endState);
                    }
                }
                else
                {

                    (context.getState()).Exit(context);
                    context.setState(AutomatFSM.Cancel_S);
                    (context.getState()).Entry(context);
                }

                return;
            }

        //-------------------------------------------------------
        // Member data.
        //
        }

        private static final class AutomatFSM_Wait_User_1_S
            extends AutomatFSM_Default
        {
        //-------------------------------------------------------
        // Member methods.
        //

            private AutomatFSM_Wait_User_1_S(String name, int id)
            {
                super (name, id);
            }

            protected void Entry(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                ctxt.wait_User_1_Entry_A();
                return;
            }

            protected void Ack_User_1_T(AutomatContext context)
            {
                Automat ctxt = context.getOwner();


                (context.getState()).Exit(context);
                context.clearState();
                try
                {
                    ctxt.ack_User_1_A();
                }
                finally
                {
                    context.setState(AutomatFSM.Wait_Seller_2_S);
                    (context.getState()).Entry(context);
                }
                return;
            }

            protected void Nack_User_1_T(AutomatContext context)
            {


                (context.getState()).Exit(context);
                context.setState(AutomatFSM.Cancel_S);
                (context.getState()).Entry(context);
                return;
            }

            protected void Timeout_3_T(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                if (ctxt.checkTimeout_3_Times() == true)
                {
                    AutomatState endState = context.getState();

                    context.clearState();
                    try
                    {
                        ctxt.timeout_3_A();
                    }
                    finally
                    {
                        context.setState(endState);
                    }
                }
                else
                {

                    (context.getState()).Exit(context);
                    context.setState(AutomatFSM.Cancel_S);
                    (context.getState()).Entry(context);
                }

                return;
            }

        //-------------------------------------------------------
        // Member data.
        //
        }

        private static final class AutomatFSM_Wait_Seller_2_S
            extends AutomatFSM_Default
        {
        //-------------------------------------------------------
        // Member methods.
        //

            private AutomatFSM_Wait_Seller_2_S(String name, int id)
            {
                super (name, id);
            }

            protected void Entry(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                ctxt.wait_Seller_2_Entry_A();
                return;
            }

            protected void Ack_Seller_2_T(AutomatContext context)
            {
                Automat ctxt = context.getOwner();


                (context.getState()).Exit(context);
                context.clearState();
                try
                {
                    ctxt.ack_Seller_2_A();
                }
                finally
                {
                    context.setState(AutomatFSM.Done_S);
                    (context.getState()).Entry(context);
                }
                return;
            }

            protected void Timeout_4_T(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                if (ctxt.checkTimeout_4_Times() == true)
                {
                    AutomatState endState = context.getState();

                    context.clearState();
                    try
                    {
                        ctxt.timeout_4_A();
                    }
                    finally
                    {
                        context.setState(endState);
                    }
                }
                else
                {

                    (context.getState()).Exit(context);
                    context.setState(AutomatFSM.Cancel_S);
                    (context.getState()).Entry(context);
                }

                return;
            }

        //-------------------------------------------------------
        // Member data.
        //
        }

        private static final class AutomatFSM_Cancel_S
            extends AutomatFSM_Default
        {
        //-------------------------------------------------------
        // Member methods.
        //

            private AutomatFSM_Cancel_S(String name, int id)
            {
                super (name, id);
            }

            protected void Entry(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                ctxt.cancel_Entry_A();
                return;
            }

        //-------------------------------------------------------
        // Member data.
        //
        }

        private static final class AutomatFSM_Done_S
            extends AutomatFSM_Default
        {
        //-------------------------------------------------------
        // Member methods.
        //

            private AutomatFSM_Done_S(String name, int id)
            {
                super (name, id);
            }

            protected void Entry(AutomatContext context)
            {
                Automat ctxt = context.getOwner();

                ctxt.done_Entry_A();
                return;
            }

        //-------------------------------------------------------
        // Member data.
        //
        }

    //-----------------------------------------------------------
    // Member data.
    //
    }
}
